﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList<System.Web.Mvc.SelectList>>" %>

<% IList<SelectList> selectedList = ViewData.Model; %>
<% SelectList categoryList = selectedList[0]; %>
<% SelectList archiveList = selectedList[1]; %>

<div class="listArchiveContainer">
    <%=Html.DropDownList("ddlArchive", archiveList, "Seçili Arşiv", new { @class = "listArchiveCombo" })%>
    <a id="archiveOk" href='#'>
        <img class="listArchiveButton" src="../../Images/ListImages/archiveok.png" alt="" />
    </a>
</div>

<div class="listCategoryContainer">
    <%=Html.DropDownList("ddlCategory", categoryList, "Seçili Kategori", new { @class = "listArchiveCombo" })%>
</div>

<script type="text/javascript">
    $(function() {
        $('#archiveOk').click(function() {
            if (selectedArchiveValidate()) {

                var categoryId = $('#ddlCategory :selected').val();
                var archiveId = $('#ddlArchive :selected').val();
                window.location.replace('/content/setDefaultArchive/?categoryId=' + categoryId + '&archiveId=' + archiveId);
            }
            else {
                return false;
            }
        });
    });
    function selectedArchiveValidate() {
        var archive = $('#ddlArchive :selected').val();
         if (archive == null || archive == "0" || archive == "" || archive == 'Seçiniz') {
            alert('Seçili arşiv boş bırakılamaz !');
            $('#ddlArchive').focus();
            return false;
        }
        else {
            return true;
        }
    }
</script>



